<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">

  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify-darklight-theme@3/dist/docsify-themeable/style.min.css"/>

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css" title="light"/>
  <link rel="stylesheet alternative" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple-dark.css" title="dark"/>
  <style>
    :root {
      --theme-color: hsl(340, 60%, 60%);
      --notice-tip-border-color: hsl(210, 85%, 60%);
      --notice-important-border-color: hsl(340, 95%, 50%);
    }
    .sidebar-nav {
      p {
        margin-top: 4px;
        margin-bottom: 4px;
      }
    }
  </style>

  <link rel="stylesheet" href="https://unpkg.com/docsify-plugin-toc@1.3.1/dist/light.css">
  <style>
    aside.toc-nav {
      top: 200px;
      width: 300px;
      right: 1%;
      margin-right: 0px;
      background-color: var(--base-background-color);
    }
    @media only screen and (max-width: 1299px) {
      aside.toc-nav {
        background-color: var(--sidebar-background);
      }
    }

    .page_toc div {
      padding: 0px;
    }
    .page_toc > div[class^="lv"] {
      padding-bottom: 4px;

      & > a {
        line-height: unset;
      }
    }
    .page_toc > div.lv2 {
      padding-top: 8px;
      padding-bottom: 0px;

      & > a > span {
        font-weight: 600;
      }
    }

    section.content:has(> .toc-nav.nothing) {
      padding-right: 0px;
    }
    body.close .sidebar+.content {
      transform: none;
    }
  </style>
</head>
<body>
  <div id="app"></div>
  <script src="//cdn.jsdelivr.net/npm/docsify-edit-on-github"></script>
  <script>
    window.$docsify = {
      name: '🏛<br/>Full House Templates',
      repo: 'stdword/logseq13-full-house-plugin#readme',
      coverpage: true,
      onlyCover: true,
      loadSidebar: true,
      subMaxLevel: 1,
      autoHeader: true,
      nameLink: '#/index',
      relativePath: true,
      auto2top: true,

      search: {
        hideOtherSidebarContent: true,
        placeholder: {
          '/': 'Type to search',
          '/ru/': 'Введите текст для поиска',
        },
        noData: {
          '/': 'No Results',
          '/ru/': 'Ничего не найдено',
        },
      },
      copyCode: {
        buttonText: {
          '/'      : 'Copy',
          '/ru/'   : 'Скопировать',
        },
        errorText: {
          '/'      : 'Error',
          '/ru/'   : 'Ошибка',
        },
        successText: {
          '/'      : 'Copied',
          '/ru/'   : 'Скопировано',
        }
      },
      pagination: {
        previousText: {
          '/': 'PREVIOUS',
          '/ru/': 'НАЗАД',
        },
        nextText: {
          '/': 'NEXT',
          '/ru/': 'ДАЛЬШЕ',
        },
        crossChapter: true,
        crossChapterText: true,
      },
      tabs: {
        persist: false,
        sync: false,
        theme: 'classic',
        tabComments: false,
        tabHeadings: true,
      },
      toc: {
        tocMaxLevel: 4,
        target: 'h2, h3, h4',
        ignoreHeaders:  []
      },
      // 'flexible-alerts': {
      //   style: 'flat'
      // },

      plugins: [
        EditOnGithubPlugin.create(
          'https://github.com/stdword/logseq13-full-house-plugin/tree/main/docs/',
          null,
          function(file) {
            if (file.indexOf('ru/') >= 0) {
              return 'Править на GitHub'
            } else {
              return 'Edit on GitHub'
            }
          }
        )
      ],
    }
  </script>
  <script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
  <style>
    .sidebar-nav li.active > a, .sidebar-nav li[class] > a {
      border-color: var(--sidebar-nav-link-border-color--active);
      color: var(--sidebar-nav-link-color--active);
    }
  </style>

  <script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/zoom-image.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
  <script src="//unpkg.com/docsify-pagination/dist/docsify-pagination.min.js"></script>

  <script src="//cdn.jsdelivr.net/npm/docsify-tabs@1"></script>
  <script>
    function fixTabs() {
      const uriComponent = window.location.hash || window.location.search;
      const anchorID = (uriComponent.match(/(?:id=)([^&]+)/) || [])[1]
      if (!anchorID)
        return

      const anchorElement = document.querySelector('#' + decodeURIComponent(anchorID));

      function adjust(treshold = 3, interval = 20, pixelDelta = 4) {
        if (adjust.state !== null) {
          if (window.pageYOffset == adjust.state) {
            adjust.settledCount++
            if (adjust.settledCount > treshold) {
              if (Math.abs(window.pageYOffset - anchorElement.offsetTop) > pixelDelta)
                window.scrollTo({top: anchorElement.offsetTop, behavior: 'smooth'});
              else return
            }
          }
        }

        if (adjust.state === null || adjust.settledCount <= treshold)
          setTimeout(adjust, interval)
        adjust.state = window.pageYOffset
      }
      adjust.settledCount = 0
      adjust.state = null

      if (anchorElement)
        adjust()
    }

    function docsifyTabsFix(hook, vm) {
      hook.doneEach(function () {
        const hasTabs = document.querySelector(`.docsify-tabs__tab`);
        if (hasTabs)
          fixTabs()
      });
    }

    window.$docsify = window.$docsify || {};
    window.$docsify.plugins = [].concat(window.$docsify.plugins || [], docsifyTabsFix);
  </script>
  <style>
    .docsify-tabs:not(:has(> button.docsify-tabs__tab--active)) > .docsify-tabs__content[class]:nth-child(2) {
      visibility: visible;
      position: relative;
      overflow: auto;
      height: auto;

      padding: var(--docsifytabs-content-padding);
    }
  </style>

  <!-- <script src="https://unpkg.com/docsify-plugin-flexible-alerts"></script> -->

  <script src="//cdn.jsdelivr.net/npm/docsify-example-panels@1"></script>
  <style>
    :root {
      --docsify-example-panels-left-panel-width: 40%;
      --docsify-example-panels-right-panel-width: 60%;
    }
  </style>

  <!-- docsify-plugin-toc -->
  <script>
    // source: https://github.com/stdword/docsify-plugin-toc/blob/patch-3/src/toc.js

    // To collect headings and then add to the page ToC
    function pageToC() {
      var commentsIterator = document.createNodeIterator(
        document.querySelector('#main'),
        NodeFilter.SHOW_COMMENT,
      )
      while(commentsIterator.nextNode()) {
        var commentNode = commentsIterator.referenceNode
        if (commentNode.textContent.trim() === '{docsify-ignore-all}')
          return ''
      }

      let toc = ['<div class="page_toc">']
      const list = []
      const ignoreHeaders = window.$docsify.toc.ignoreHeaders || []

      const headings = document.querySelectorAll(`#main ${window.$docsify.toc.target}`)
      if (headings)
        headings.forEach(function (heading) {
          const innerText = heading.innerText
          const innerHtml = heading.innerHTML

          let needSkip = false
          if (ignoreHeaders.length > 0)
            needSkip = ignoreHeaders.some(str => innerText.match(str))

          const node = heading.nextSibling
          if (node.nodeType === node.COMMENT_NODE && node.textContent.trim() === '{docsify-ignore}')
            needSkip = true

          if (needSkip)
            return

          const item = generateToC(heading.tagName.replace(/h/gi, ''), innerHtml)
          if (item)
            list.push(item)
        })

      if (list.length > 0) {
        toc = toc.concat(list)
        toc.push('</div>')
        return toc.join('')
      }

      return ''
    }

    // To generate each ToC item
    function generateToC(level, html) {
      if (level >= 1 && level <= window.$docsify.toc.tocMaxLevel) {
        const heading = ['<div class="lv' + level + '">', html, '</div>'].join('')
        return heading
      }
      return ''
    }

    // scroll listener
    const scrollHandler = () => {
      const toc = {}
      const tocList = []
      document.querySelectorAll('.page_toc > div').forEach((el) => {
        const ref = el.firstElementChild.attributes['data-id'].value
        toc[ref] = el
        tocList.push(ref)
      })

      if (tocList.length === 0)
        return

      const clientHeight = window.innerHeight
      const visibleHeadings = []
      const headings = document.querySelectorAll(`#main ${window.$docsify.toc.target}`)

      headings.forEach((h) => {
        const ref = h.attributes['id'].value
        if (!toc[ref])
          return

        const rect = h.getBoundingClientRect()
        if (rect.top <= clientHeight && rect.top + rect.height > 0)
          visibleHeadings.push(ref)
      })

      let hightlighted = null
      const scrollingElement = document.scrollingElement || document.body
      const maxOffset = scrollingElement.scrollHeight - window.innerHeight

      // scrolled to top, choose the first one
      if (window.pageYOffset === 0)
        hightlighted = tocList[0]
      else if (Math.abs(window.pageYOffset - maxOffset) < 5) {
        // scrolled to bottom, choose the last one
        hightlighted = tocList.at(-1)
      }
      else if (visibleHeadings.length > 0)
        hightlighted = visibleHeadings[0]

      if (hightlighted)
        tocList.forEach((h) => {
          const el = toc[h]
          if (h === hightlighted) {
            el.classList.add('active')
            const item = el.getBoundingClientRect()
            const box = el.parentElement.parentElement.getBoundingClientRect()
            const visibleFully = item.top > box.top && item.bottom < box.bottom
            if (!visibleFully)
              el.scrollIntoView({behavior: 'smooth'})
          }
          else
            el.classList.remove('active')
        })
    }

    // adjust event click target due to docsify bug:
    //    click event will be successful only if
    //    event.target is «A» tag or the child of «A» tag
    //    but it can bee deeper
    function adjustClickEventTarget(event) {
      if (event._adjusted ||
          event.target.tagName === 'A' ||
          event.target.parentNode.tagName === 'A'
      )
        return

      var link = event.target.closest('a.anchor[data-id]')
      if (!link)
        return

      event.preventDefault()
      var adjustedEvent = document.createEvent('MouseEvent')
      adjustedEvent.initEvent('click', true, true)
      adjustedEvent._adjusted = true

      link.dispatchEvent(adjustedEvent)
    }

    function install(hook, vm) {
      hook.mounted(function () {
        const content = window.Docsify.dom.find('.content')
        if (content) {
          const nav = window.Docsify.dom.create('aside', '')
          window.Docsify.dom.toggleClass(nav, 'add', 'toc-nav')
          window.Docsify.dom.before(content, nav)
          nav.addEventListener('click', adjustClickEventTarget)
        }
      })
      hook.doneEach(function () {
        const nav = window.Docsify.dom.find('.toc-nav')
        if (nav) {
          nav.innerHTML = pageToC().trim()
          if (nav.innerHTML === '') {
            window.Docsify.dom.toggleClass(nav, 'add', 'nothing')
            window.document.removeEventListener('scroll', scrollHandler)
          } else {
            window.Docsify.dom.toggleClass(nav, 'remove', 'nothing')
            scrollHandler()
            window.document.addEventListener('scroll', scrollHandler)
          }
        }
      })
    }

    if (!window.$docsify) {
      window.$docsify = {}
    }

    window.$docsify.plugins = (window.$docsify.plugins || []).concat(install)
  </script>

  <script src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@3/dist/docsify-themeable/main.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@3/dist/docsify-themeable/index.min.js"></script>
</body>
</html>
